/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  权限管理页
 * @author  wangxin | xinwang200110@sohu-inc.com
 * @version 1.0 | 2013-04-17
 * @param
 * @example
 */

$require('cpt.LJSDefine');
//$require('cpt.search');
$require('cpt.allSelect');
$require('cpt.addAuthGroup');
$require('cpt.editAuthGroup');

LJS.define('page.authManage',function(ljs){
   //搜索部分初始化
   //ljs.cpt.search.init();
   
   //全选、删除功能初始化
   ljs.cpt.allSelect.init('del_group', 'POST');
   
   $('[event_type=addAuthGroups]').on('click',function(){
					ljs.cpt.addAuthGroup.showAdd()					   
										   
	})
   
   // event_type="edGroup" event_data="这里是id"
   $('[event_type=edGroup]').on('click',function(){
			// event_data="这里是权限ids" id="这里是id" node_name
			var resource_id = this.getAttribute("resource_ids");
	   var role_id = this.getAttribute("id");
	   	ljs.cpt.editAuthGroup.showAdd(role_id,resource_id)
			var that = this;
			$.ajax({
			  type: "get",
			  url: "getGroup.txt",
			  dataType: "json",
			  data:{id: $(this).attr('id')},
			  cache:false,
			  success:function(json){
				  if(json.status=='100000'){
					  ljs.cpt.addAuthGroup.showAdd({
						 id: $(that).attr('id'),
						 name: $(that).attr('node_name'),
						 ids: json.content
					})	
				  }
			  }
			})					   
	})
});